package com.itheima.web;
/**
 * Create By Awen on 2021/8/25
 *
 * @author Awen
 */

import com.itheima.pojo.Result;
import com.itheima.pojo.Role;
import com.itheima.service.RoleService;
import com.itheima.utils.BeanFactory;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/role")
public class RoleServlet extends BaseServlet {
    private RoleService roleService = (RoleService) BeanFactory.getBean("RoleService");

    public void selectRoleList(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try {
            List<Role> list = roleService.queryRoleList();
            Result result = new Result(true, "", list);
            BaseController.responseJson(response, result);
        } catch (Exception e) {
            e.printStackTrace();
            Result result = new Result(false, "服务器忙请稍后重试.....", null);
            BaseController.responseJson(response, result);
        }
    }


}
